{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "b825fcf0-cacc-4427-b633-42b191b14e77",
   "metadata": {},
   "outputs": [
    {
     "name": "stdin",
     "output_type": "stream",
     "text": [
      "请输入年份:  2023\n",
      "请输入月份:  10\n",
      "请输入日期:  5\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2023年10月5日是这一年的第278天。\n"
     ]
    }
   ],
   "source": [
    "import datetime\n",
    "\n",
    "def day_of_year(year, month, day):\n",
    "    # 创建一个datetime对象\n",
    "    date = datetime.date(year, month, day)\n",
    "    # 使用timetuple()方法将date对象转换为struct_time对象，然后获取tm_yday属性\n",
    "    # tm_yday属性表示这一天是这一年的第几天\n",
    "    return date.timetuple().tm_yday\n",
    "\n",
    "def main():\n",
    "    # 获取用户输入的年、月、日\n",
    "    year = int(input(\"请输入年份: \"))\n",
    "    month = int(input(\"请输入月份: \"))\n",
    "    day = int(input(\"请输入日期: \"))\n",
    "    \n",
    "    # 调用day_of_year函数计算这一天是这一年的第几天\n",
    "    result = day_of_year(year, month, day)\n",
    "    \n",
    "    # 输出结果\n",
    "    print(f\"{year}年{month}月{day}日是这一年的第{result}天。\")\n",
    "\n",
    "if __name__ == \"__main__\":\n",
    "    main()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5f235aad-3766-4b8e-b01d-ef5c25910639",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.13.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
